<%@page import="java.io.FileOutputStream"%>
<%@page import="java.io.OutputStream"%>
<%@page import="java.io.File"%>
<%@page import="com.office.automate.service.impl.employee.EmployeeServiceImplementer"%>
<%@page import="com.office.automate.model.employee.Employee"%>
<%@page import="com.office.automate.configuration.property.ConfigurationProperties"%>
<%@page import="java.util.Properties"%>
<%@page import="java.util.List"%>
<%@page import="com.office.automate.frontier.utility.DataConversionUtility"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.office.automate.frontier.utility.ExceptionMessagesManagement"%>
<%@page import="com.office.automate.validation.framework.ValidatorObject"%>
<%@page import="com.office.automate.exception.framework.FrontierVisibleException"%>
<%@page import="java.util.HashMap"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ include file="../common/CommonHeaderInfo.jsp"%>
<title>Update Employee</title>
</head>
<body>
	<%@ include file="../common/SiteHeaderSection.jsp" %>
	<%@ include file="../common/MainMenuBar.jsp"%>

		<%
			boolean isValidationErrorExist = false;
			ExceptionMessagesManagement exceptionMessagesManagement  = null;
			Properties configProperties = ConfigurationProperties.getProps();
			DataConversionUtility dataConversionUtility = new DataConversionUtility();
			Employee employee = new EmployeeServiceImplementer().getEmployeeDetails(currentUser.getEmployeeId());
			ValidatorObject validationErrors = (ValidatorObject) request.getAttribute("FieldValidationErrors");
			
		%>
		<tr>
		<td>
		<form action="/OfficeAutomation/UploadPhotoServlet" method="post" enctype="multipart/form-data">
		<center>
		<table>
			<tr>
				<td colspan="3"><center><font class="formtablecaption"><u>Upload Employee Profile Image</u></font></center><br /></td>
			</tr>
			<tr>
			<%
			if (validationErrors != null) {
				exceptionMessagesManagement = new ExceptionMessagesManagement(validationErrors.getValidationErrorList());
				isValidationErrorExist = true;
			}
			%>
				  <td>
				  <center>
						<table class="mainContentStyles">
							<tr>
								<td>
								<center>
								<%
									if (employee != null && employee.getImage() != null) {
								 %>
								 		<img src="/OfficeAutomation/EmployeeImageServlet?employeeId=<%=employee.getEmployeeId() %>" width="200" height="250" >
								 <%
									} else {
								%>
									<img src="<%=configProperties.getProperty("EMPLOYEE_DETAILS_IMAGE_DEFAULT") %>" width="200" height="250" >
								<%
									}
								%>
								</center>
								</td>
							</tr>
							<%
							 if (isValidationErrorExist && exceptionMessagesManagement.checkExistenceOfErrorByKey("ProfileImage")) {
							%>
								<tr>
									<td colspan="2"><font class="errorMessageStyles"> <%=exceptionMessagesManagement.getDetailExceptionMessage("ProfileImage")  %> </font></td>
								</tr>
							<%
							 }
							%>
						<tr>
							<td>
								<input type="file" name="profileImage" >
							</td>
						</tr>
						</table>
					</center>
					</td>
				</tr>
				<tr>
					<td colspan="3"><div class="formButtonPanel"><input type="submit" name="submit" value="Upload Image" /></div></td>
				</tr>
			</table>
		  </center>
		</form>
	  </td>
	</tr>
<%@ include file="../common/SiteFotterSection.jsp" %>
</body>
</html>